package com.cskaoyan.advice;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.stereotype.Component;

@Component
public class CustomAdvice implements MethodInterceptor {
    //类似于InvocationHandler的invoke
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        Object aThis = methodInvocation.getThis();
        //methodInvocation.getMethod().getName().equals("sayHello")
        //when what
        //执行的是委托类的方法 👉 类似于method.invoke
        Object proceed = methodInvocation.proceed();
        System.out.println("照在大地上");
        return proceed;
    }
}
